import { ApiProperty } from '@nestjs/swagger';
import { CrudValidationGroups } from '@nestjsx/crud';
import { IsNumber, IsString, IsOptional } from 'class-validator';
import {
  Column,
  Entity,
} from 'typeorm';
import { NationEnum } from './enum/nation.enum';
import { SexEnum } from './enum/sex.enum';


@Entity()
export class VillagerInfo {
  @ApiProperty({
    example: '名字',
    description: '名字',
    required: true,
  })
  @IsString({ always: true })
  @Column({
    // nullable: true,
    name: "name",
    type: "char",
    length: 255,
  })
  name: string;

  @ApiProperty({
    example: SexEnum.men,
    description: '性别',
    required: true,
    enum: SexEnum,
  })
  @IsNumber({}, { always: true })
  @Column({
    name: "sex",
    type: "enum",
    enum: SexEnum,
  })
  sex: SexEnum;

  @ApiProperty({
    example: NationEnum.HAN,
    description: '民族',
    required: true,
    enum: NationEnum,
  })
  @IsNumber({}, { always: true })
  @IsOptional()
  @Column({
    nullable: true,
    name: "nation",
    type: "enum",
    enum: NationEnum,
  })
  nation?: NationEnum;

  // @ApiProperty({
  //   example: 176666666666,
  //   description: '电话',
  //   required: true,
  // })
  // @IsNumber({}, { always: true })
  // @Column({
  //   nullable: true,
  //   name: "phone",
  // })
  // phone?: number;

  @ApiProperty({
    example: 5555555555,
    description: '身份证号',
    required: true,
  })
  @IsString({ always: true })
  @Column({
    nullable: true,
    name: "identityNumber",
    type: "char",
    length: 255,
  })
  identityNumber?: string;

  @ApiProperty({
    example: '地址',
    description: '地址',
    required: true,
  })
  @IsString({ always: true })
  @Column({
    nullable: true,
    name: "address",
    type: "char",
    length: 255,
  })
  address?: string;
}


